Using Jquery $getJSON How do I dynamically create data for the [data] parameter after Url param?

Posted by Breadtruck on Stack Overflow See other posts from Stack Overflow or by Breadtruck
Published on 2010-03-14T12:10:33Z Indexed on 2010/03/14 12:15 UTC
Read the original article Hit count: 292

Filed under:
|
|

I have no problems getting the Json to work and parse the json return. I was just wondering how I could build a dynamic "whatever data is" and stick it into [data] to pass my parameters from there and not manually append them to the url.

From jquery website example:

$.getJSON("test.js", { name: "John", time: "2pm" }, function(json){
     alert("JSON Data: " + json.users[3].name);
});

I thought I could build a string ( which doesn't make sense anyway ) and drop it inside the { }, but I obviously don't understand that part.

name: isn't a string and you can't put a variable in that part, so how would I dynamically put items into whatever [data] is.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON